package com.bj58.mis.bigdata.mdp.sys.controller;

import com.bj58.bsp.v2.Provider;
import com.bj58.bsp.v2.exception.BspException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/bsp/user")
public class BspUserController {
    /**
     * 分页查询用户列表
     * @param page
     * @param limit
     * @return
     * @throws BspException
     */
    @RequestMapping("")
    public Object queryPage(@RequestParam(name="page",defaultValue = "1") Integer page,
                            @RequestParam(name="limit",defaultValue = "10") Integer limit,
                            @RequestParam(name="status",defaultValue = "1") Integer status) throws BspException {
        return Provider.getUserService().getUserPageList(page, limit, status);
    }

    /**
     * 根据用户 id 查询用户信息
     * @param userId
     * @return
     * @throws BspException
     */
    @RequestMapping("/{userId}")
    public Object get(@PathVariable("userId") String userId) throws BspException {
        return Provider.getUserService().getUserById(userId);
    }
    /**
     * 根据用户 id 查询用户信息
     * @param userId
     * @return
     * @throws BspException
     */
    @RequestMapping("/{userId}/extinfo")
    public Object getExtinfo(@PathVariable("userId") String userId) throws BspException {
        return Provider.getUserService().getUserExtInfo(userId);
    }



    /**
     * 查询用户负责的部门列表
     * @param orgId
     * @return
     * @throws BspException
     */
    @RequestMapping("/{userId}/managedOrgs")
    public Object getManagedOrgs(@PathVariable("userId") String userId) throws BspException {
        return Provider.getUserService().getManagedOrgs(userId);
    }

    /**
     * 查询用户负责的部门列表
     * @param orgId
     * @return
     * @throws BspException
     */
    @RequestMapping("/{userId}/subordinates")
    public Object getSubordinate(@PathVariable("userId") String userId) throws BspException {
        return Provider.getUserService().getSubordinate(userId);
    }
}
